// 基于 SnowLang Project (https://gitee.com/jcnc-org/snow) 的衍生作品
// 原始版权归属: Copyright © 2025 Ke Xu (Luke)
// 本实现版权归属: Copyright © 2025 Sany
// 遵循 Apache License 2.0 授权
package control

import (
	"errors"
	"strconv"

	"gitee.com/xntk2381/cc/vm/module"
)

type DPushCommand struct{}

func (DPushCommand) Execute(parts []string, currentPC int, operandStack *module.OperandStack, localVariableStore *module.LocalVariableStore, callStack *module.CallStack) (int, error) {
	if len(parts) < 2 {
		return 0, errors.New("no target command address specified for DPUSH operation")
	}
	valI, err := strconv.Atoi(parts[1])
	if err != nil {
		return 0, errors.New("invalid target command address specified for DPUSH operation")
	}
	value := float64(valI)
	operandStack.Push(value)
	return currentPC + 1, nil
}
